package org.jwcloud.project.module.zx.taskSupervision.controller;

import com.jw.mid.mm.comm.common.controller.BaseController;
import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;
import com.jw.mid.mm.comm.common.pagination.Pagination;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.taskSupervision.service.TaskSuperviseService;
import org.jwcloud.project.module.zx.timingSz.service.RptTimingSzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(value = "API - Controlle",
        description = "项目进度管理", tags = "projectProgressManagement")
@RestController
@RequestMapping("/rest/taskSupervise")
public class TaskSuperviseController extends BaseController {

    @Autowired
    public TaskSuperviseService taskSuperviseService;

    @GetMapping("queryTaskSuperviseWarnList")
    @ApiOperation(value = "任务督办提醒", notes = "任务督办提醒  分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "project_name", value = "project_name", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "duty_dept", value = "duty_dept", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "is_done", value = "is_done", required = false, dataType = "string", paramType = "query"),
    })
    public Resp<Response<PageListSlice>> queryTaskSuperviseList(
            Pagination pagination,
            @RequestParam(required = false) Map<String,String> param
    ) {
        return taskSuperviseService.queryTaskSupervise(pagination, param);
    }


    @GetMapping("queryTaskOvertimeList")
    @ApiOperation(value = "任务超时预警", notes = "任务超时预警  分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "project_name", value = "project_name", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "duty_dept", value = "duty_dept", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "is_done", value = "is_done", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "cron_type", value = "cron_type", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "reply_flag", value = "reply_flag", required = false, dataType = "string", paramType = "query"),
            
            
            @ApiImplicitParam(name = "finish_state", value = "01 未完成  02按时完成  '03超时完成'},", required = false, dataType = "string", paramType = "query"),
    })
    public Resp<Response<PageListSlice>> queryTaskOverTimeListInfo(
            Pagination pagination,
            @RequestParam(required = false) Map<String,String> param
    ) {
        return taskSuperviseService.queryTaskOverTimeWarning(pagination, param);
    }


    @PostMapping("taskOvertimeFeedback")
    @ApiOperation(value = "任务超时预警反馈", notes = "任务超时预警反馈")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "reason_type", value = "任务超时原因", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "duty_person", value = "责任人", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "overtime_content", value = "超时原因", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "handle_content", value = "整改措施", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string", paramType = "query"),
    })
    public Resp<Object> taskOvertimeFeedbackController(
            @RequestBody(required = false) Map<String,String> param
    ) {
    	
    	String flag = FmtUtil.nullRes(param
				, "id", "id"
				, "reason_type", "任务超时原因"
				, "overtime_content", "超时原因"
				, "handle_content", "整改措施");
		if(!StringUtils.isEmpty(flag)) 
			return Resp.error(flag);
    	
        return taskSuperviseService.taskOvertimeFeedbackInfo(param);
    }


}